package com.buka.order.service.serviceImpl;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.buka.order.mapper.TaskMapper;
import com.buka.order.service.TaskService;
import com.buka.pojo.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TaskServiceImpl implements TaskService {
    @Autowired
    private TaskMapper taskMapper;

    @Override
    public void add(Task task) {
        task.setId(IdWorker.getId());
        taskMapper.insertSelective(task);
    }

    @Override
    public void update(Task task) {
        task.setUpdateTime(new Date());
        taskMapper.updateByPrimaryKeySelective(task);
    }

    @Override
    public void delete(Long id) {
        taskMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Task> findList(Task task) {
        return taskMapper.select(task);
    }
}